import 'package:kk/model/common_model.dart';
import 'package:kk/model/config_model.dart';
import 'package:kk/model/grid_nav_model.dart';
import 'package:kk/model/sales_box_model.dart';

class HomeModel {
  final ConfigModel? config;
  final List<CommonModel> bannerList;
  List<CommonModel> localNavList = [];
  final List<CommonModel> subNavList;
  final GridNavModel gridNav;
  final SalesBoxModel salesBox;

  HomeModel(
      {this.config,
      required this.bannerList,
      required this.localNavList,
      required this.subNavList,
      required this.gridNav,
      required this.salesBox});

  factory HomeModel.fromJson(Map<String, dynamic> json) {
    var localNavListJson = json["localNavList"] as List;
    List<CommonModel> localNavList =
        localNavListJson.map((i) => CommonModel.fromJson(i)).toList();

    var bannerListJson = json["bannerList"] as List;
    List<CommonModel> bannerList =
        bannerListJson.map((i) => CommonModel.fromJson(i)).toList();

    var subNavListJson = json["subNavList"] as List;
    List<CommonModel> subNavList =
        subNavListJson.map((e) => CommonModel.fromJson(e)).toList();

    return HomeModel(
        localNavList: localNavList,
        bannerList: bannerList,
        subNavList: subNavList,
        config: ConfigModel.fromJson(json["config"]),
        gridNav: GridNavModel.fromJson(json["gridNav"]),
        salesBox: SalesBoxModel.fromJson(json["salesBox"]));
  }

  Map toJson() {
    Map map = {
      localNavList: localNavList,
      bannerList: bannerList,
      subNavList: subNavList,
      config: config,
      gridNav: gridNav,
      salesBox: salesBox,
    };
    return map;
  }
}
